var express = require('express');
var router = express.Router();
var mongoose = require('mongoose');
var user = require('../models/user');

/* GET home page. */
router.get('/', function (req, res, next) {
  res.render('index', {
    title: 'Express'
  });
});
router.post('/showUser', function (req, res, next) {
  // if (!req.body.user_id) {
  //     res.json({status: 1, message: "用户状态出错"})
  // }
  user.findById(req.body.user_id, function (err, getUser) {
    res.json({
      status: 0,
      message: "获取成功",
      data: {
        user_id: getUser._id,
        username: getUser.username,
        userMail: getUser.userMail,
        userPhone: getUser.userPhone,
        userAdmin: getUser.userAdmin
      }
    })
  })
});
router.get('/showAllUser', function (req, res, next) {
  user.find({}, function (err,doc) {
      res.json({
        states:1,
        msg:doc
      })
  })
  })

module.exports = router;